Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #18087

I started from fixing an incremental crash from fixup.py, but then noticed we don't traverse ParamSpec prefix in multiple places where we should, so I fixed most of those as well.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I grepped for \.upper_bound at the HEAD of this PR and inspected the matches, and I haven't found any missing cases (except for one that probably shouldn't be changed as process_param_spec_def looks like something that should only run for definitions, although I can't find where it is actually called).

def visit_param_spec(self, typ: ParamSpecType) -> None:
typ.upper_bound.accept(self)
typ.default.accept(self)
typ.prefix.accept(self)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should NodeReplaceVisitor above do the same? More importantly, why isn't its process_param_spec_def actually ever called (as well as process_type_var_tuple_def)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to #14872 where process_param_spec_def was added, but apparently not connected to anything? It should probably be...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ParamSpec definitions cannot have prefixes, it is purely mypy-internal thing to represent Concatenate in the type system. Also I noticed that process_param_spec_def() and process_type_var_tuple_def() are not called anywhere. Probably they should be called from visit_class_def(). But this is definitely a topic for a separate issue/PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I remember what a PSpec prefix means:) I just wasn't able to make sure that process_param_spec_def is actually called on definitions and not on other ParamSpec occurrences

@ilevkivskyi ilevkivskyi merged commit bf77aab into python:master Sep 6, 2025
20 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-prefix-crash-2 branch September 6, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal error: De-serialization failure: TypeInfo not fixed

2 participants